package client;

import bean.RequestWrapper;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AbstractClient implements Client {

    @Override
    public Object invokeSync(Object msg, int timeout, int codecType, int protocolType) throws Exception {
        RequestWrapper requestWrapper = new RequestWrapper(msg, timeout, codecType, protocolType);
        return invokeSyncInternal(requestWrapper);
    }

    @Override
    public Object invokeSync(String targetInstanceName, String methodName, String[] argTypes, Object[] args, int timeout, int codecType, int protocolType) throws Exception {
        byte[][] argTypeBytes = new byte[argTypes.length][];
        for(int i =0; i < argTypes.length; i++) {
            argTypeBytes[i] =  argTypes[i].getBytes();
        }
        RequestWrapper requestWrapper = new RequestWrapper(targetInstanceName.getBytes(), methodName.getBytes(), argTypeBytes, args, timeout, codecType, protocolType);
        return invokeSyncInternal(requestWrapper);
    }

    private Object invokeSyncInternal(RequestWrapper requestWrapper) {

        return null;
    }
}
